import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

class Solution819 {
    public static void main(String[] args) {

       String s = "Bob hit a ball, .the hit? BALL flew? far ?after it was hit.";
       String[] arr = { "hit" } ;
        System.out.println(mostCommonWord(s, arr));

    }
    public static String mostCommonWord(String paragraph, String[] banned) {
        HashSet<String> set = new HashSet<>() ;
        for(String str : banned){
            set.add(str) ;
        }
        paragraph =  paragraph.toLowerCase() ;
        Map<String , Integer> map = new HashMap<>() ;
        int max = 0 ;
        String maxS = null ;
        char[] arr = paragraph.toCharArray() ;
        int n = arr.length ;
        for(int i= 0 ; i < n ; i ++){
            int j=i ;
            if(arr[i] >= 'a' && arr[i] <= 'z'){
                while(j < n && arr[j] >= 'a' && arr[j] <= 'z') {
                    j ++;
                }
                String str = new String(arr , i , j-i) ;
                if(!set.contains(str)){
                    map.put(str , map.getOrDefault(str , 0)+1) ;
                    if(map.get(str) > max){
                        max = map.get(str) ;
                        maxS = str ;
                    }

                }
                i = j ;
            }
        }
        return maxS ;
    }
}